/*      */ package com.zimbra.qa.unittest.prov.ldap;
/*      */ 
/*      */ import com.google.common.collect.Lists;
/*      */ import com.zimbra.cs.account.Provisioning;
/*      */ import com.zimbra.cs.account.Server;
/*      */ import com.zimbra.cs.account.ldap.LdapEntrySearchFilter;
/*      */ import com.zimbra.cs.ldap.LdapException;
/*      */ import com.zimbra.cs.ldap.LdapUtil;
/*      */ import com.zimbra.cs.ldap.ZLdapFilter;
/*      */ import com.zimbra.cs.ldap.ZLdapFilterFactory;
/*      */ import com.zimbra.cs.ldap.ZLdapFilterFactory.FilterId;
/*      */ import com.zimbra.qa.QA.Bug;
/*      */ import java.io.PrintStream;
/*      */ import java.util.List;
/*      */ import org.junit.Assert;
/*      */ import org.junit.BeforeClass;
/*      */ import org.junit.Test;
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ public class TestLdapZLdapFilter
/*      */   extends LdapTest
/*      */ {
/*      */   private static LdapProvTestUtil provUtil;
/*      */   private static Provisioning prov;
/*      */   private static ZLdapFilterFactory filterDactory;
/*      */   
/*      */   @BeforeClass
/*      */   public static void init()
/*      */     throws Exception
/*      */   {
/*   44 */     provUtil = new LdapProvTestUtil();
/*   45 */     prov = provUtil.getProv();
/*   46 */     filterDactory = ZLdapFilterFactory.getInstance();
/*      */   }
/*      */   
/*      */ 
/*      */   private static class LegacyLdapFilter
/*      */   {
/*      */     private static final String FILTER_ACCOUNT_OBJECTCLASS = "(objectClass=zimbraAccount)";
/*      */     
/*      */     private static final String FILTER_ACCOUNT_ONLY_OBJECTCLASS = "(&(objectClass=zimbraAccount)(!(objectClass=zimbraCalendarResource)))";
/*      */     private static final String FILTER_ALIAS_OBJECTCLASS = "(objectClass=zimbraAlias)";
/*      */     private static final String FILTER_CALENDAR_RESOURCE_OBJECTCLASS = "(objectClass=zimbraCalendarResource)";
/*      */     private static final String FILTER_DISTRIBUTION_LIST_OBJECTCLASS = "(objectClass=zimbraDistributionList)";
/*      */     private static final String FILTER_DYNAMIC_GROUP_OBJECTCLASS = "(objectClass=zimbraGroup)";
/*      */     private static final String FILTER_GROUP_OBJECTCLASS = "(|(objectClass=zimbraGroup)(objectClass=zimbraDistributionList))";
/*      */     
/*      */     public static String hasSubordinates()
/*      */     {
/*   63 */       return "(hasSubordinates=TRUE)";
/*      */     }
/*      */     
/*      */     public static String createdLaterOrEqual(String generalizedTime) {
/*   67 */       return "(createTimestamp>=" + generalizedTime + ")";
/*      */     }
/*      */     
/*      */ 
/*      */ 
/*      */     public static String anyEntry()
/*      */     {
/*   74 */       return "(objectClass=*)";
/*      */     }
/*      */     
/*      */     public static String presenceFilter(String attr)
/*      */     {
/*   79 */       return "(" + attr + "=*" + ")";
/*      */     }
/*      */     
/*      */     public static String equalityFilter(String attr, String value) {
/*   83 */       return "(" + attr + "=" + value + ")";
/*      */     }
/*      */     
/*      */     public static String greaterOrEqualFilter(String attr, String value) {
/*   87 */       return "(" + attr + ">=" + value + ")";
/*      */     }
/*      */     
/*      */     public static String lessOrEqualFilter(String attr, String value) {
/*   91 */       return "(" + attr + "<=" + value + ")";
/*      */     }
/*      */     
/*      */     public static String startsWithFilter(String attr, String value)
/*      */     {
/*   96 */       return "(" + attr + "=" + value + "*)";
/*      */     }
/*      */     
/*      */     public static String endsWithFilter(String attr, String value)
/*      */     {
/*  101 */       return "(" + attr + "=*" + value + ")";
/*      */     }
/*      */     
/*      */     public static String substringFilter(String attr, String value)
/*      */     {
/*  106 */       return "(" + attr + "=*" + value + "*)";
/*      */     }
/*      */     
/*      */     public static String andWith(String filter, String otherFilter) {
/*  110 */       return "(&" + filter + otherFilter + ")";
/*      */     }
/*      */     
/*      */     public static String negate(String filter) {
/*  114 */       return "(!" + filter + ")";
/*      */     }
/*      */     
/*      */ 
/*      */ 
/*      */     public static String addrsExist(String[] addrs)
/*      */     {
/*  121 */       StringBuilder buf = new StringBuilder();
/*  122 */       buf.append("(|");
/*  123 */       for (int i = 0; i < addrs.length; i++) {
/*  124 */         buf.append(String.format("(%s=%s)", new Object[] { "zimbraMailDeliveryAddress", addrs[i] }));
/*  125 */         buf.append(String.format("(%s=%s)", new Object[] { "zimbraMailAlias", addrs[i] }));
/*      */       }
/*  127 */       buf.append(")");
/*      */       
/*  129 */       return buf.toString();
/*      */     }
/*      */     
/*      */ 
/*      */ 
/*      */     public static String allAccounts()
/*      */     {
/*  136 */       return "(objectClass=zimbraAccount)";
/*      */     }
/*      */     
/*      */     public static String allAccountsOnly() {
/*  140 */       return "(&(objectClass=zimbraAccount)(!(objectClass=zimbraCalendarResource)))";
/*      */     }
/*      */     
/*      */     public static String allAdminAccounts() {
/*  144 */       return "(&(objectClass=zimbraAccount)(|(zimbraIsAdminAccount=TRUE)(zimbraIsDelegatedAdminAccount=TRUE)(zimbraIsDomainAdminAccount=TRUE)))";
/*      */     }
/*      */     
/*      */ 
/*      */     public static String allNonSystemAccounts()
/*      */     {
/*  150 */       StringBuilder buf = new StringBuilder();
/*  151 */       buf.append("(&");
/*  152 */       buf.append("(objectClass=zimbraAccount)(!(objectClass=zimbraCalendarResource))");
/*  153 */       buf.append("(!(zimbraIsSystemResource=TRUE))");
/*  154 */       buf.append(")");
/*      */       
/*  156 */       return buf.toString();
/*      */     }
/*      */     
/*      */     public static String accountByForeignPrincipal(String foreignPrincipal) {
/*  160 */       return "(&(zimbraForeignPrincipal=" + foreignPrincipal + ")" + "(objectClass=zimbraAccount)" + ")";
/*      */     }
/*      */     
/*      */     public static String accountById(String id) {
/*  164 */       return "(&(zimbraId=" + id + ")" + "(objectClass=zimbraAccount)" + ")";
/*      */     }
/*      */     
/*      */     public static String accountByName(String name) {
/*  168 */       return "(&(|(zimbraMailDeliveryAddress=" + name + ")(zimbraMailAlias=" + name + "))" + "(objectClass=zimbraAccount)" + ")";
/*      */     }
/*      */     
/*      */     public static String accountByMemberOf(String dynGroupId) {
/*  172 */       return "(&(zimbraMemberOf=" + dynGroupId + ")" + "(objectClass=zimbraAccount)" + ")";
/*      */     }
/*      */     
/*      */     public static String adminAccountByRDN(String namingRdnAttr, String name) {
/*  176 */       return "(&(" + namingRdnAttr + "=" + name + ")" + "(objectClass=zimbraAccount)" + ")";
/*      */     }
/*      */     
/*      */     public static String accountsHomedOnServer(String serverServiceHostname) {
/*  180 */       return "(&(objectClass=zimbraAccount)" + homedOnServer(serverServiceHostname) + ")";
/*      */     }
/*      */     
/*      */     public static String accountsHomedOnServerAccountsOnly(String serverServiceHostname) {
/*  184 */       return "(&(&(objectClass=zimbraAccount)(!(objectClass=zimbraCalendarResource)))" + homedOnServer(serverServiceHostname) + ")";
/*      */     }
/*      */     
/*      */     public static String externalAccountsHomedOnServer(String serverServiceHostname) {
/*  188 */       return "(&(&(objectClass=zimbraAccount)(!(objectClass=zimbraCalendarResource)))" + externalAccount() + homedOnServer(serverServiceHostname) + ")";
/*      */     }
/*      */     
/*      */     public static String externalAccount() {
/*  192 */       return "(zimbraIsExternalVirtualAccount=TRUE)";
/*      */     }
/*      */     
/*      */     public static String accountsByExternalGrant(String granteeEmail) {
/*  196 */       return String.format("(&%s(zimbraSharedItem=granteeId:%s*))", new Object[] { "(objectClass=zimbraAccount)", granteeEmail });
/*      */     }
/*      */     
/*      */     public static String accountsByGrants(List<String> granteeIds, boolean includePublicShares, boolean includeAllAuthedShares)
/*      */     {
/*  201 */       StringBuilder searchQuery = new StringBuilder().append("(&(objectClass=zimbraAccount)(|");
/*  202 */       for (String id : granteeIds) {
/*  203 */         searchQuery.append(String.format("(zimbraSharedItem=granteeId:%s*)", new Object[] { id }));
/*      */       }
/*  205 */       if (includePublicShares) {
/*  206 */         searchQuery.append("(zimbraSharedItem=*granteeType:pub*)");
/*      */       }
/*  208 */       if (includeAllAuthedShares) {
/*  209 */         searchQuery.append("(zimbraSharedItem=*granteeType:all*)");
/*      */       }
/*  211 */       searchQuery.append("))");
/*      */       
/*  213 */       return searchQuery.toString();
/*      */     }
/*      */     
/*      */     public static String CMBSearchAccountsOnly() {
/*  217 */       return "(&(&(objectClass=zimbraAccount)(!(objectClass=zimbraCalendarResource)))(|(!(zimbraExcludeFromCMBSearch=*))(zimbraExcludeFromCMBSearch=FALSE)))";
/*      */     }
/*      */     
/*      */ 
/*      */ 
/*      */     public static String CMBSearchAccountsOnlyWithArchive()
/*      */     {
/*  224 */       return "(&(&(objectClass=zimbraAccount)(!(objectClass=zimbraCalendarResource)))(&(zimbraArchiveAccount=*)(|(!(zimbraExcludeFromCMBSearch=*))(zimbraExcludeFromCMBSearch=FALSE))))";
/*      */     }
/*      */     
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */     public static String CMBSearchNonSystemResourceAccountsOnly()
/*      */     {
/*  234 */       return "(&(&(objectClass=zimbraAccount)(!(objectClass=zimbraCalendarResource)))(&(!(zimbraIsSystemResource=*))(|(!(zimbraExcludeFromCMBSearch=*))(zimbraExcludeFromCMBSearch=FALSE))))";
/*      */     }
/*      */     
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */     public static String homedOnServer(String serverServiceHostname)
/*      */     {
/*  244 */       return "(zimbraMailHost=" + serverServiceHostname + ")";
/*      */     }
/*      */     
/*      */     public static String accountsOnServerOnCosHasSubordinates(String serverServiceHostname, String cosId) {
/*  248 */       return "(&" + allAccounts() + homedOnServer(serverServiceHostname) + hasSubordinates() + "(|(!(" + "zimbraCOSId" + "=*))" + "(" + "zimbraCOSId" + "=" + cosId + ")))";
/*      */     }
/*      */     
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */     public static String allAliases()
/*      */     {
/*  258 */       return "(objectClass=zimbraAlias)";
/*      */     }
/*      */     
/*      */ 
/*      */ 
/*      */     public static String allCalendarResources()
/*      */     {
/*  265 */       return "(objectClass=zimbraCalendarResource)";
/*      */     }
/*      */     
/*      */     public static String calendarResourceByForeignPrincipal(String foreignPrincipal) {
/*  269 */       return "(&(zimbraForeignPrincipal=" + foreignPrincipal + ")" + "(objectClass=zimbraCalendarResource)" + ")";
/*      */     }
/*      */     
/*      */     public static String calendarResourceById(String id) {
/*  273 */       return "(&(zimbraId=" + id + ")" + "(objectClass=zimbraCalendarResource)" + ")";
/*      */     }
/*      */     
/*      */     public static String calendarResourceByName(String name) {
/*  277 */       return "(&(|(zimbraMailDeliveryAddress=" + name + ")(zimbraMailAlias=" + name + "))" + "(objectClass=zimbraCalendarResource)" + ")";
/*      */     }
/*      */     
/*      */     public static String calendarResourcesHomedOnServer(String serverServiceHostname) {
/*  281 */       return "(&(objectClass=zimbraCalendarResource)" + homedOnServer(serverServiceHostname) + ")";
/*      */     }
/*      */     
/*      */ 
/*      */ 
/*      */     public static String allCoses()
/*      */     {
/*  288 */       return "(objectClass=zimbraCOS)";
/*      */     }
/*      */     
/*      */     public static String cosById(String id) {
/*  292 */       return "(&(zimbraId=" + id + ")(objectClass=zimbraCOS))";
/*      */     }
/*      */     
/*      */     public static String cosesByMailHostPool(String server) {
/*  296 */       return "(&(objectClass=zimbraCOS)(zimbraMailHostPool=" + server + "))";
/*      */     }
/*      */     
/*      */ 
/*      */ 
/*      */     public static String allDataSources()
/*      */     {
/*  303 */       return "(objectClass=zimbraDataSource)";
/*      */     }
/*      */     
/*      */     public static String dataSourceById(String id) {
/*  307 */       return "(&(objectClass=zimbraDataSource)(zimbraDataSourceId=" + id + "))";
/*      */     }
/*      */     
/*      */     public static String dataSourceByName(String name) {
/*  311 */       return "(&(objectClass=zimbraDataSource)(zimbraDataSourceName=" + name + "))";
/*      */     }
/*      */     
/*      */ 
/*      */ 
/*      */     public static String allDistributionLists()
/*      */     {
/*  318 */       return "(objectClass=zimbraDistributionList)";
/*      */     }
/*      */     
/*      */     public static String distributionListById(String id) {
/*  322 */       return "(&(zimbraId=" + id + ")" + "(objectClass=zimbraDistributionList)" + ")";
/*      */     }
/*      */     
/*      */     public static String distributionListByName(String name) {
/*  326 */       return "(&(zimbraMailAlias=" + name + ")" + "(objectClass=zimbraDistributionList)" + ")";
/*      */     }
/*      */     
/*      */     public static String distributionListsByMemberAddrs(String[] memberAddrs) {
/*  330 */       StringBuilder sb = new StringBuilder();
/*  331 */       if (memberAddrs.length > 1) {
/*  332 */         sb.append("(|");
/*      */       }
/*  334 */       for (int i = 0; i < memberAddrs.length; i++) {
/*  335 */         sb.append(String.format("(%s=%s)", new Object[] { "zimbraMailForwardingAddress", memberAddrs[i] }));
/*      */       }
/*  337 */       if (memberAddrs.length > 1) {
/*  338 */         sb.append(")");
/*      */       }
/*      */       
/*  341 */       return "(&(objectClass=zimbraDistributionList)" + sb.toString() + ")";
/*      */     }
/*      */     
/*      */ 
/*      */ 
/*      */     public static String dynamicGroupById(String id)
/*      */     {
/*  348 */       return "(&(zimbraId=" + id + ")" + "(objectClass=zimbraGroup)" + ")";
/*      */     }
/*      */     
/*      */     public static String dynamicGroupByName(String name) {
/*  352 */       return "(&(zimbraMailAlias=" + name + ")" + "(objectClass=zimbraGroup)" + ")";
/*      */     }
/*      */     
/*      */ 
/*      */ 
/*      */ 
/*      */     public static String allGroups()
/*      */     {
/*  360 */       return "(|(objectClass=zimbraGroup)(objectClass=zimbraDistributionList))";
/*      */     }
/*      */     
/*      */     public static String groupById(String id) {
/*  364 */       return "(&(zimbraId=" + id + ")" + "(|(objectClass=zimbraGroup)(objectClass=zimbraDistributionList))" + ")";
/*      */     }
/*      */     
/*      */     public static String groupByName(String name) {
/*  368 */       return "(&(zimbraMailAlias=" + name + ")" + "(|(objectClass=zimbraGroup)(objectClass=zimbraDistributionList))" + ")";
/*      */     }
/*      */     
/*      */ 
/*      */ 
/*      */ 
/*      */     public static String allDomains()
/*      */     {
/*  376 */       return "(objectClass=zimbraDomain)";
/*      */     }
/*      */     
/*      */     public static String domainById(String id) {
/*  380 */       return "(&(zimbraId=" + id + ")(objectClass=zimbraDomain))";
/*      */     }
/*      */     
/*      */     public static String domainByName(String name) {
/*  384 */       return "(&(zimbraDomainName=" + name + ")(objectClass=zimbraDomain))";
/*      */     }
/*      */     
/*      */     public static String domainByKrb5Realm(String krb5Realm) {
/*  388 */       return "(&(zimbraAuthKerberos5Realm=" + krb5Realm + ")(objectClass=zimbraDomain))";
/*      */     }
/*      */     
/*      */     public static String domainByVirtualHostame(String virtualHostname) {
/*  392 */       return "(&(zimbraVirtualHostname=" + virtualHostname + ")(objectClass=zimbraDomain))";
/*      */     }
/*      */     
/*      */     public static String domainByForeignName(String foreignName) {
/*  396 */       return "(&(zimbraForeignName=" + foreignName + ")(objectClass=zimbraDomain))";
/*      */     }
/*      */     
/*      */     public static String domainLabel() {
/*  400 */       return "(objectClass=dcObject)";
/*      */     }
/*      */     
/*      */     public static String domainLockedForEagerAutoProvision() {
/*  404 */       return "(!(zimbraAutoProvLock=*))";
/*      */     }
/*      */     
/*      */ 
/*      */ 
/*      */ 
/*      */     public static String globalConfig()
/*      */     {
/*  412 */       return "(cn=config)";
/*      */     }
/*      */     
/*      */ 
/*      */ 
/*      */ 
/*      */     public static String allIdentities()
/*      */     {
/*  420 */       return "(objectClass=zimbraIdentity)";
/*      */     }
/*      */     
/*      */     public static String identityByName(String name) {
/*  424 */       return "(&(objectClass=zimbraIdentity)(zimbraPrefIdentityName=" + name + "))";
/*      */     }
/*      */     
/*      */ 
/*      */ 
/*      */     public static String allMimeEntries()
/*      */     {
/*  431 */       return "(objectClass=zimbraMimeEntry)";
/*      */     }
/*      */     
/*      */     public static String mimeEntryByMimeType(String mimeType) {
/*  435 */       return "(zimbraMimeType=" + mimeType + ")";
/*      */     }
/*      */     
/*      */ 
/*      */ 
/*      */     public static String allServers()
/*      */     {
/*  442 */       return "(objectClass=zimbraServer)";
/*      */     }
/*      */     
/*      */     public static String serverById(String id) {
/*  446 */       return "(&(zimbraId=" + id + ")(objectClass=zimbraServer))";
/*      */     }
/*      */     
/*      */     public static String serverByService(String service) {
/*  450 */       return "(&(objectClass=zimbraServer)(zimbraServiceEnabled=" + service + "))";
/*      */     }
/*      */     
/*      */ 
/*      */ 
/*      */     public static String shareLocatorById(String id)
/*      */     {
/*  457 */       return "(&(cn=" + id + ")(objectClass=zimbraShareLocator))";
/*      */     }
/*      */     
/*      */ 
/*      */ 
/*      */     public static String allSignatures()
/*      */     {
/*  464 */       return "(objectClass=zimbraSignature)";
/*      */     }
/*      */     
/*      */     public static String signatureById(String id) {
/*  468 */       return "(&(objectClass=zimbraSignature)(zimbraSignatureId=" + id + "))";
/*      */     }
/*      */     
/*      */ 
/*      */ 
/*      */ 
/*      */     public static String allXMPPComponents()
/*      */     {
/*  476 */       return "(objectClass=zimbraXMPPComponent)";
/*      */     }
/*      */     
/*      */     public static String imComponentById(String id) {
/*  480 */       return "(&(objectClass=zimbraXMPPComponent)(zimbraXMPPComponentId=" + id + "))";
/*      */     }
/*      */     
/*      */     public static String xmppComponentById(String id) {
/*  484 */       return "(&(zimbraId=" + id + ")(objectClass=zimbraXMPPComponent))";
/*      */     }
/*      */     
/*      */ 
/*      */ 
/*      */ 
/*      */     public static String allZimlets()
/*      */     {
/*  492 */       return "(objectClass=zimbraZimletEntry)";
/*      */     }
/*      */     
/*      */ 
/*      */ 
/*      */ 
/*      */     public static String memberOf(String dnOfGroup)
/*      */     {
/*  500 */       return "(memberOf=" + dnOfGroup + ")";
/*      */     }
/*      */     
/*      */ 
/*      */ 
/*      */ 
/*      */     private static String velodromePrimaryEmailOnDomainFilter(String domainName)
/*      */     {
/*  508 */       return "(zimbraMailDeliveryAddress=*@" + domainName + ")";
/*      */     }
/*      */     
/*      */     public static String velodromeAllAccountsByDomain(String domainName) {
/*  512 */       return "(&(objectClass=zimbraAccount)" + velodromePrimaryEmailOnDomainFilter(domainName) + ")";
/*      */     }
/*      */     
/*      */     public static String velodromeAllAccountsOnlyByDomain(String domainName) {
/*  516 */       return "(&(&(objectClass=zimbraAccount)(!(objectClass=zimbraCalendarResource)))" + velodromePrimaryEmailOnDomainFilter(domainName) + ")";
/*      */     }
/*      */     
/*      */     public static String velodromeAllCalendarResourcesByDomain(String domainName) {
/*  520 */       return "(&(objectClass=zimbraCalendarResource)" + velodromePrimaryEmailOnDomainFilter(domainName) + ")";
/*      */     }
/*      */     
/*      */     public static String velodromeAllAccountsByDomainAndServer(String domainName, String serverServiceHostname) {
/*  524 */       return "(&(objectClass=zimbraAccount)" + homedOnServer(serverServiceHostname) + velodromePrimaryEmailOnDomainFilter(domainName) + ")";
/*      */     }
/*      */     
/*      */ 
/*      */     public static String velodromeAllAccountsOnlyByDomainAndServer(String domainName, String serverServiceHostname)
/*      */     {
/*  530 */       return "(&(&(objectClass=zimbraAccount)(!(objectClass=zimbraCalendarResource)))" + homedOnServer(serverServiceHostname) + velodromePrimaryEmailOnDomainFilter(domainName) + ")";
/*      */     }
/*      */     
/*      */ 
/*      */     public static String velodromeAllCalendarResourcesByDomainAndServer(String domainName, String serverServiceHostname)
/*      */     {
/*  536 */       return "(&(objectClass=zimbraCalendarResource)" + homedOnServer(serverServiceHostname) + velodromePrimaryEmailOnDomainFilter(domainName) + ")";
/*      */     }
/*      */     
/*      */ 
/*      */     public static String dnSubtreeMatch(String... dns)
/*      */     {
/*  542 */       StringBuffer sb = new StringBuffer();
/*  543 */       sb.append("(|");
/*  544 */       for (String dn : dns) {
/*  545 */         sb.append(String.format("(entryDN:dnSubtreeMatch:=%s)", new Object[] { dn }));
/*      */       }
/*  547 */       sb.append(")");
/*      */       
/*  549 */       return sb.toString();
/*      */     }
/*      */     
/*      */     private static void printFilter(String doc, String usage, String base, String filter)
/*      */     {
/*  554 */       System.out.println();
/*  555 */       System.out.println(doc);
/*  556 */       System.out.println("usage:  " + usage);
/*  557 */       System.out.println("base:   " + base);
/*  558 */       System.out.println("filter: " + filter);
/*      */     }
/*      */   }
/*      */   
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */   private String genUUID()
/*      */   {
/*  755 */     return LdapUtil.generateUUID();
/*      */   }
/*      */   
/*      */   private void verifyStatString(ZLdapFilterFactory.FilterId filterId, ZLdapFilter zLdapFilter) throws Exception {
/*  759 */     Assert.assertEquals(filterId.getStatString(), zLdapFilter.getStatString());
/*      */   }
/*      */   
/*      */   private void verify(ZLdapFilterFactory.FilterId filterId, String expected, ZLdapFilter actual) throws Exception
/*      */   {
/*  764 */     String filter = actual.toFilterString();
/*  765 */     Assert.assertEquals(expected, filter);
/*  766 */     verifyStatString(filterId, actual);
/*      */   }
/*      */   
/*      */   private void verify(ZLdapFilterFactory.FilterId filterId, ZLdapFilter expected, ZLdapFilter actual) throws Exception
/*      */   {
/*  771 */     Assert.assertEquals(expected.toFilterString(), actual.toFilterString());
/*  772 */     verifyStatString(filterId, actual);
/*      */   }
/*      */   
/*      */   @Test
/*      */   public void hasSubordinates() throws Exception {
/*  777 */     String filter = LegacyLdapFilter.hasSubordinates();
/*  778 */     ZLdapFilter zLdapFilter = filterDactory.hasSubordinates();
/*  779 */     verify(ZLdapFilterFactory.FilterId.HAS_SUBORDINATES, filter, zLdapFilter);
/*      */   }
/*      */   
/*      */   @Test
/*      */   public void createdLaterOrEqual() throws Exception {
/*  784 */     String GENERALIZED_TIME = "20111005190522Z";
/*      */     
/*  786 */     String filter = LegacyLdapFilter.createdLaterOrEqual(GENERALIZED_TIME);
/*  787 */     ZLdapFilter zLdapFilter = filterDactory.createdLaterOrEqual(GENERALIZED_TIME);
/*  788 */     verify(ZLdapFilterFactory.FilterId.CREATED_LATEROREQUAL, filter, zLdapFilter);
/*      */   }
/*      */   
/*      */   @Test
/*      */   public void anyEntry() throws Exception {
/*  793 */     String filter = LegacyLdapFilter.anyEntry();
/*  794 */     ZLdapFilter zLdapFilter = filterDactory.anyEntry();
/*  795 */     verify(ZLdapFilterFactory.FilterId.ANY_ENTRY, filter, zLdapFilter);
/*      */   }
/*      */   
/*      */   @Test
/*      */   public void fromFilterString() throws Exception {
/*  800 */     String FILTER_STR = "(blah=123)";
/*  801 */     ZLdapFilter zLdapFilter = filterDactory.fromFilterString(ZLdapFilterFactory.FilterId.AUTO_PROVISION_SEARCH, FILTER_STR);
/*      */     
/*  803 */     verify(ZLdapFilterFactory.FilterId.AUTO_PROVISION_SEARCH, FILTER_STR, zLdapFilter);
/*      */   }
/*      */   
/*      */   @Test
/*      */   public void andWith() throws Exception {
/*  808 */     String FILTER1 = "(foo=1)";
/*  809 */     String FILTER2 = "(bar=2)";
/*      */     
/*  811 */     String filter = LegacyLdapFilter.andWith(FILTER1, FILTER2);
/*  812 */     ZLdapFilter zLdapFilter = filterDactory.andWith(filterDactory.fromFilterString(ZLdapFilterFactory.FilterId.ADMIN_SEARCH, FILTER1), filterDactory.fromFilterString(ZLdapFilterFactory.FilterId.UNITTEST, FILTER2));
/*      */     
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*  818 */     verify(ZLdapFilterFactory.FilterId.ADMIN_SEARCH, filter, zLdapFilter);
/*      */   }
/*      */   
/*      */   @Test
/*      */   public void negate() throws Exception {
/*  823 */     String FILTER = "(foo=bar)";
/*      */     
/*  825 */     String filter = LegacyLdapFilter.negate(FILTER);
/*  826 */     ZLdapFilter zLdapFilter = filterDactory.negate(filterDactory.fromFilterString(ZLdapFilterFactory.FilterId.UNITTEST, FILTER));
/*      */     
/*  828 */     verify(ZLdapFilterFactory.FilterId.UNITTEST, filter, zLdapFilter);
/*      */   }
/*      */   
/*      */   @Test
/*      */   public void presenceFilter() throws Exception {
/*  833 */     String ATTR = "foo";
/*      */     
/*  835 */     String filter = filterDactory.presenceFilter(ATTR);
/*  836 */     Assert.assertEquals("(foo=*)", filter);
/*      */   }
/*      */   
/*      */   @Test
/*      */   public void equalityFilter() throws Exception {
/*  841 */     String ATTR = "foo";
/*  842 */     String VALUE_RAW = "bar*()\\";
/*  843 */     String VALUE_ESCAPED = "bar\\2a\\28\\29\\5c";
/*      */     
/*  845 */     String filterFromRaw = filterDactory.equalityFilter(ATTR, VALUE_RAW, true);
/*  846 */     String filterFromEscaped = filterDactory.equalityFilter(ATTR, VALUE_ESCAPED, false);
/*  847 */     Assert.assertEquals(filterFromRaw, filterFromEscaped);
/*      */   }
/*      */   
/*      */   @Test
/*      */   public void greaterOrEqualFilter() throws Exception {
/*  852 */     String ATTR = "foo";
/*  853 */     String VALUE_RAW = "bar*()\\";
/*  854 */     String VALUE_ESCAPED = "bar\\2a\\28\\29\\5c";
/*      */     
/*  856 */     String filterFromRaw = filterDactory.greaterOrEqualFilter(ATTR, VALUE_RAW, true);
/*  857 */     String filterFromEscaped = filterDactory.greaterOrEqualFilter(ATTR, VALUE_ESCAPED, false);
/*  858 */     Assert.assertEquals(filterFromRaw, filterFromEscaped);
/*      */   }
/*      */   
/*      */   @Test
/*      */   public void lessOrEqualFilter() throws Exception {
/*  863 */     String ATTR = "foo";
/*  864 */     String VALUE_RAW = "bar*()\\";
/*  865 */     String VALUE_ESCAPED = "bar\\2a\\28\\29\\5c";
/*      */     
/*  867 */     String filterFromRaw = filterDactory.lessOrEqualFilter(ATTR, VALUE_RAW, true);
/*  868 */     String filterFromEscaped = filterDactory.lessOrEqualFilter(ATTR, VALUE_ESCAPED, false);
/*  869 */     Assert.assertEquals(filterFromRaw, filterFromEscaped);
/*      */   }
/*      */   
/*      */   @Test
/*      */   public void startsWithFilter() throws Exception {
/*  874 */     String ATTR = "foo";
/*  875 */     String VALUE_RAW = "bar*()\\";
/*  876 */     String VALUE_ESCAPED = "bar\\2a\\28\\29\\5c";
/*      */     
/*  878 */     String filterFromRaw = filterDactory.startsWithFilter(ATTR, VALUE_RAW, true);
/*  879 */     String filterFromEscaped = filterDactory.startsWithFilter(ATTR, VALUE_ESCAPED, false);
/*  880 */     Assert.assertEquals(filterFromRaw, filterFromEscaped);
/*      */   }
/*      */   
/*      */   @Test
/*      */   public void endsWithFilter() throws Exception {
/*  885 */     String ATTR = "foo";
/*  886 */     String VALUE_RAW = "bar*()\\";
/*  887 */     String VALUE_ESCAPED = "bar\\2a\\28\\29\\5c";
/*      */     
/*  889 */     String filterFromRaw = filterDactory.endsWithFilter(ATTR, VALUE_RAW, true);
/*  890 */     String filterFromEscaped = filterDactory.endsWithFilter(ATTR, VALUE_ESCAPED, false);
/*  891 */     Assert.assertEquals(filterFromRaw, filterFromEscaped);
/*      */   }
/*      */   
/*      */   @Test
/*      */   public void substringFilter() throws Exception {
/*  896 */     String ATTR = "foo";
/*  897 */     String VALUE_RAW = "bar*()\\";
/*  898 */     String VALUE_ESCAPED = "bar\\2a\\28\\29\\5c";
/*      */     
/*  900 */     String filterFromRaw = filterDactory.substringFilter(ATTR, VALUE_RAW, true);
/*  901 */     String filterFromEscaped = filterDactory.substringFilter(ATTR, VALUE_ESCAPED, false);
/*  902 */     Assert.assertEquals(filterFromRaw, filterFromEscaped);
/*      */   }
/*      */   
/*      */   @Test
/*      */   public void addrsExist() throws Exception {
/*  907 */     String[] ADDRS = { "addr1@test.com", "addr2@test.com", "addr2@test.com" };
/*      */     
/*  909 */     String filter = LegacyLdapFilter.addrsExist(ADDRS);
/*  910 */     ZLdapFilter zLdapFilter = filterDactory.addrsExist(ADDRS);
/*  911 */     verify(ZLdapFilterFactory.FilterId.ADDRS_EXIST, filter, zLdapFilter);
/*      */   }
/*      */   
/*      */   @Test
/*      */   public void allAccounts() throws Exception {
/*  916 */     String filter = LegacyLdapFilter.allAccounts();
/*  917 */     ZLdapFilter zLdapFilter = filterDactory.allAccounts();
/*  918 */     verify(ZLdapFilterFactory.FilterId.ALL_ACCOUNTS, filter, zLdapFilter);
/*      */   }
/*      */   
/*      */   @Test
/*      */   public void allAccountsOnly() throws Exception {
/*  923 */     String filter = LegacyLdapFilter.allAccountsOnly();
/*  924 */     ZLdapFilter zLdapFilter = filterDactory.allAccountsOnly();
/*  925 */     verify(ZLdapFilterFactory.FilterId.ALL_ACCOUNTS_ONLY, filter, zLdapFilter);
/*      */   }
/*      */   
/*      */   @Test
/*      */   public void allAdminAccounts() throws Exception {
/*  930 */     String filter = LegacyLdapFilter.allAdminAccounts();
/*  931 */     ZLdapFilter zLdapFilter = filterDactory.allAdminAccounts();
/*  932 */     verify(ZLdapFilterFactory.FilterId.ALL_ADMIN_ACCOUNTS, filter, zLdapFilter);
/*      */   }
/*      */   
/*      */   @Test
/*      */   public void allNonSystemAccounts() throws Exception {
/*  937 */     String filter = LegacyLdapFilter.allNonSystemAccounts();
/*      */     
/*      */ 
/*  940 */     ZLdapFilter zLdapFilter = filterDactory.allNonSystemAccounts();
/*  941 */     String zFilter = zLdapFilter.toFilterString();
/*      */     
/*      */ 
/*      */ 
/*  945 */     verifyStatString(ZLdapFilterFactory.FilterId.ALL_NON_SYSTEM_ACCOUNTS, zLdapFilter);
/*      */   }
/*      */   
/*      */   @Test
/*      */   public void accountByForeignPrincipal() throws Exception {
/*  950 */     String FOREIFN_PRINCIPAL = getTestName();
/*      */     
/*  952 */     String filter = LegacyLdapFilter.accountByForeignPrincipal(FOREIFN_PRINCIPAL);
/*  953 */     ZLdapFilter zLdapFilter = filterDactory.accountByForeignPrincipal(FOREIFN_PRINCIPAL);
/*  954 */     verify(ZLdapFilterFactory.FilterId.ACCOUNT_BY_FOREIGN_PRINCIPAL, filter, zLdapFilter);
/*      */   }
/*      */   
/*      */   @Test
/*      */   public void accountById() throws Exception {
/*  959 */     String ID = genUUID();
/*      */     
/*  961 */     String filter = LegacyLdapFilter.accountById(ID);
/*  962 */     ZLdapFilter zLdapFilter = filterDactory.accountById(ID);
/*  963 */     verify(ZLdapFilterFactory.FilterId.ACCOUNT_BY_ID, filter, zLdapFilter);
/*      */   }
/*      */   
/*      */   @Test
/*      */   public void accountByMemberOf() throws Exception {
/*  968 */     String MEMBEROF = getTestName();
/*      */     
/*  970 */     String filter = LegacyLdapFilter.accountByMemberOf(MEMBEROF);
/*  971 */     ZLdapFilter zLdapFilter = filterDactory.accountByMemberOf(MEMBEROF);
/*  972 */     verify(ZLdapFilterFactory.FilterId.ACCOUNT_BY_MEMBEROF, filter, zLdapFilter);
/*      */   }
/*      */   
/*      */   @Test
/*      */   public void accountByName() throws Exception {
/*  977 */     String NAME = getTestName();
/*      */     
/*  979 */     String filter = LegacyLdapFilter.accountByName(NAME);
/*  980 */     ZLdapFilter zLdapFilter = filterDactory.accountByName(NAME);
/*  981 */     verify(ZLdapFilterFactory.FilterId.ACCOUNT_BY_NAME, filter, zLdapFilter);
/*      */   }
/*      */   
/*      */   @Test
/*      */   public void adminAccountByRDN() throws Exception {
/*  986 */     String NAMING_RDN_ATTR = "uid";
/*  987 */     String NAME = getTestName();
/*      */     
/*  989 */     String filter = LegacyLdapFilter.adminAccountByRDN(NAMING_RDN_ATTR, NAME);
/*  990 */     ZLdapFilter zLdapFilter = filterDactory.adminAccountByRDN(NAMING_RDN_ATTR, NAME);
/*  991 */     verify(ZLdapFilterFactory.FilterId.ADMIN_ACCOUNT_BY_RDN, filter, zLdapFilter);
/*      */   }
/*      */   
/*      */   @Test
/*      */   public void accountsHomedOnServer() throws Exception {
/*  996 */     Server SERVER = prov.getLocalServer();
/*      */     
/*  998 */     String filter = LegacyLdapFilter.accountsHomedOnServer(SERVER.getServiceHostname());
/*  999 */     ZLdapFilter zLdapFilter = filterDactory.accountsHomedOnServer(SERVER.getServiceHostname());
/* 1000 */     verify(ZLdapFilterFactory.FilterId.ACCOUNTS_HOMED_ON_SERVER, filter, zLdapFilter);
/*      */   }
/*      */   
/*      */   @Test
/*      */   public void accountsHomedOnServerAccountOnly() throws Exception {
/* 1005 */     Server SERVER = prov.getLocalServer();
/*      */     
/* 1007 */     String filter = LegacyLdapFilter.accountsHomedOnServerAccountsOnly(SERVER.getServiceHostname());
/* 1008 */     ZLdapFilter zLdapFilter = filterDactory.accountsHomedOnServerAccountsOnly(SERVER.getServiceHostname());
/* 1009 */     verify(ZLdapFilterFactory.FilterId.ACCOUNTS_HOMED_ON_SERVER_ACCOUNTS_ONLY, filter, zLdapFilter);
/*      */   }
/*      */   
/*      */   @Test
/*      */   public void homedOnServer() throws Exception {
/* 1014 */     Server SERVER = prov.getLocalServer();
/*      */     
/* 1016 */     String filter = LegacyLdapFilter.homedOnServer(SERVER.getServiceHostname());
/* 1017 */     ZLdapFilter zLdapFilter = filterDactory.homedOnServer(SERVER.getServiceHostname());
/* 1018 */     verify(ZLdapFilterFactory.FilterId.HOMED_ON_SERVER, filter, zLdapFilter);
/*      */   }
/*      */   
/*      */   @Test
/*      */   public void accountsOnServerAndCosHasSubordinates() throws Exception {
/* 1023 */     Server SERVER = prov.getLocalServer();
/* 1024 */     String COS_ID = genUUID();
/*      */     
/* 1026 */     String filter = LegacyLdapFilter.accountsOnServerOnCosHasSubordinates(SERVER.getServiceHostname(), COS_ID);
/* 1027 */     ZLdapFilter zLdapFilter = filterDactory.accountsOnServerAndCosHasSubordinates(SERVER.getServiceHostname(), COS_ID);
/* 1028 */     verify(ZLdapFilterFactory.FilterId.ACCOUNTS_ON_SERVER_AND_COS_HAS_SUBORDINATES, filter, zLdapFilter);
/*      */   }
/*      */   
/*      */   @Test
/*      */   public void accountsByGrants() throws Exception {
/* 1033 */     List<String> GRANTEE_IDS = Lists.newArrayList(new String[] { "GRANTEE-ID-1", "GRANTEE-ID-2", "..." });
/* 1034 */     boolean includePublicShares = true;
/* 1035 */     boolean includeAllAuthedShares = true;
/*      */     
/*      */ 
/* 1038 */     StringBuilder searchQuery = new StringBuilder().append("(&(objectClass=zimbraAccount)(|");
/* 1039 */     for (String id : GRANTEE_IDS) {
/* 1040 */       searchQuery.append(String.format("(zimbraSharedItem=granteeId:%s*)", new Object[] { id }));
/*      */     }
/* 1042 */     if (includePublicShares) {
/* 1043 */       searchQuery.append("(zimbraSharedItem=*granteeType:pub*)");
/*      */     }
/* 1045 */     if (includeAllAuthedShares) {
/* 1046 */       searchQuery.append("(zimbraSharedItem=*granteeType:all*)");
/*      */     }
/* 1048 */     searchQuery.append("))");
/*      */     
/* 1050 */     String legacyFilter = searchQuery.toString();
/*      */     
/* 1052 */     String filter = LegacyLdapFilter.accountsByGrants(GRANTEE_IDS, includePublicShares, includeAllAuthedShares);
/* 1053 */     ZLdapFilter zLdapFilter = filterDactory.accountsByGrants(GRANTEE_IDS, includePublicShares, includeAllAuthedShares);
/*      */     
/* 1055 */     Assert.assertEquals(legacyFilter, filter);
/* 1056 */     verify(ZLdapFilterFactory.FilterId.ACCOUNTS_BY_GRANTS, filter, zLdapFilter);
/*      */   }
/*      */   
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */   @Test
/*      */   public void CMBSearchAccountsOnly()
/*      */     throws Exception
/*      */   {
/* 1069 */     String legacyFilter = "(&(&(objectClass=zimbraAccount)(!(objectClass=zimbraCalendarResource)))(|(!(zimbraExcludeFromCMBSearch=*))(zimbraExcludeFromCMBSearch=FALSE)))";
/*      */     
/*      */ 
/* 1072 */     String filter = LegacyLdapFilter.CMBSearchAccountsOnly();
/*      */     
/*      */ 
/* 1075 */     ZLdapFilter zLdapFilter = filterDactory.CMBSearchAccountsOnly();
/*      */     
/* 1077 */     Assert.assertEquals(legacyFilter, filter);
/* 1078 */     verify(ZLdapFilterFactory.FilterId.CMB_SEARCH_ACCOUNTS_ONLY, filter, zLdapFilter);
/*      */   }
/*      */   
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */   @Test
/*      */   public void CMBSearchAccountsOnlyWithArchive()
/*      */     throws Exception
/*      */   {
/* 1090 */     String legacyFilter = "(&(&(objectClass=zimbraAccount)(!(objectClass=zimbraCalendarResource)))(&(zimbraArchiveAccount=*)(|(!(zimbraExcludeFromCMBSearch=*))(zimbraExcludeFromCMBSearch=FALSE))))";
/*      */     
/*      */ 
/* 1093 */     String filter = LegacyLdapFilter.CMBSearchAccountsOnlyWithArchive();
/* 1094 */     Assert.assertEquals(legacyFilter, filter);
/*      */     
/* 1096 */     ZLdapFilter zLdapFilter = filterDactory.CMBSearchAccountsOnlyWithArchive();
/* 1097 */     String zFilter = zLdapFilter.toFilterString();
/*      */     
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/* 1105 */     verifyStatString(ZLdapFilterFactory.FilterId.CMB_SEARCH_ACCOUNTS_ONLY_WITH_ARCHIVE, zLdapFilter);
/*      */   }
/*      */   
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */   @Test
/*      */   public void CMBSearchNonSystemResourceAccountsOnly()
/*      */     throws Exception
/*      */   {
/* 1116 */     String legacyFilter = "(&(&(objectClass=zimbraAccount)(!(objectClass=zimbraCalendarResource)))(&(!(zimbraIsSystemResource=*))(|(!(zimbraExcludeFromCMBSearch=*))(zimbraExcludeFromCMBSearch=FALSE))))";
/*      */     
/*      */ 
/* 1119 */     String filter = LegacyLdapFilter.CMBSearchNonSystemResourceAccountsOnly();
/* 1120 */     Assert.assertEquals(legacyFilter, filter);
/*      */     
/* 1122 */     ZLdapFilter zLdapFilter = filterDactory.CMBSearchNonSystemResourceAccountsOnly();
/* 1123 */     String zFilter = zLdapFilter.toFilterString();
/*      */     
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/* 1131 */     verifyStatString(ZLdapFilterFactory.FilterId.CMB_SEARCH_NON_SYSTEM_RESOURCE_ACCOUNTS_ONLY, zLdapFilter);
/*      */   }
/*      */   
/*      */   @Test
/*      */   public void allAliases() throws Exception {
/* 1136 */     String filter = LegacyLdapFilter.allAliases();
/* 1137 */     ZLdapFilter zLdapFilter = filterDactory.allAliases();
/* 1138 */     verify(ZLdapFilterFactory.FilterId.ALL_ALIASES, filter, zLdapFilter);
/*      */   }
/*      */   
/*      */   @Test
/*      */   public void allCalendarResources() throws Exception {
/* 1143 */     String filter = LegacyLdapFilter.allCalendarResources();
/* 1144 */     ZLdapFilter zLdapFilter = filterDactory.allCalendarResources();
/* 1145 */     verify(ZLdapFilterFactory.FilterId.ALL_CALENDAR_RESOURCES, filter, zLdapFilter);
/*      */   }
/*      */   
/*      */   @Test
/*      */   public void calendarResourceByForeignPrincipal() throws Exception {
/* 1150 */     String FOREIGN_PRINCIPAL = getTestName();
/*      */     
/* 1152 */     String filter = LegacyLdapFilter.calendarResourceByForeignPrincipal(FOREIGN_PRINCIPAL);
/* 1153 */     ZLdapFilter zLdapFilter = filterDactory.calendarResourceByForeignPrincipal(FOREIGN_PRINCIPAL);
/* 1154 */     verify(ZLdapFilterFactory.FilterId.CALENDAR_RESOURCE_BY_FOREIGN_PRINCIPAL, filter, zLdapFilter);
/*      */   }
/*      */   
/*      */   @Test
/*      */   public void calendarResourceById() throws Exception {
/* 1159 */     String ID = genUUID();
/*      */     
/* 1161 */     String filter = LegacyLdapFilter.calendarResourceById(ID);
/* 1162 */     ZLdapFilter zLdapFilter = filterDactory.calendarResourceById(ID);
/* 1163 */     verify(ZLdapFilterFactory.FilterId.CALENDAR_RESOURCE_BY_ID, filter, zLdapFilter);
/*      */   }
/*      */   
/*      */   @Test
/*      */   public void calendarResourceByName() throws Exception {
/* 1168 */     String NAME = getTestName();
/*      */     
/* 1170 */     String filter = LegacyLdapFilter.calendarResourceByName(NAME);
/* 1171 */     ZLdapFilter zLdapFilter = filterDactory.calendarResourceByName(NAME);
/* 1172 */     verify(ZLdapFilterFactory.FilterId.CALENDAR_RESOURCE_BY_NAME, filter, zLdapFilter);
/*      */   }
/*      */   
/*      */   @Test
/*      */   public void calendarResourcesHomedOnServer() throws Exception {
/* 1177 */     Server SERVER = prov.getLocalServer();
/*      */     
/* 1179 */     String filter = LegacyLdapFilter.calendarResourcesHomedOnServer(SERVER.getServiceHostname());
/* 1180 */     ZLdapFilter zLdapFilter = filterDactory.calendarResourcesHomedOnServer(SERVER.getServiceHostname());
/* 1181 */     verify(ZLdapFilterFactory.FilterId.CALENDAR_RESOURCES_HOMED_ON_SERVER, filter, zLdapFilter);
/*      */   }
/*      */   
/*      */   @Test
/*      */   public void allCoses() throws Exception
/*      */   {
/* 1187 */     String filter = LegacyLdapFilter.allCoses();
/* 1188 */     ZLdapFilter zLdapFilter = filterDactory.allCoses();
/* 1189 */     verify(ZLdapFilterFactory.FilterId.ALL_COSES, filter, zLdapFilter);
/*      */   }
/*      */   
/*      */   @Test
/*      */   public void cosById() throws Exception {
/* 1194 */     String ID = genUUID();
/*      */     
/* 1196 */     String filter = LegacyLdapFilter.cosById(ID);
/* 1197 */     ZLdapFilter zLdapFilter = filterDactory.cosById(ID);
/* 1198 */     verify(ZLdapFilterFactory.FilterId.COS_BY_ID, filter, zLdapFilter);
/*      */   }
/*      */   
/*      */   @Test
/*      */   public void cosesByMailHostPool() throws Exception {
/* 1203 */     String SERVER_ID = genUUID();
/*      */     
/* 1205 */     String filter = LegacyLdapFilter.cosesByMailHostPool(SERVER_ID);
/* 1206 */     ZLdapFilter zLdapFilter = filterDactory.cosesByMailHostPool(SERVER_ID);
/* 1207 */     verify(ZLdapFilterFactory.FilterId.COSES_BY_MAILHOST_POOL, filter, zLdapFilter);
/*      */   }
/*      */   
/*      */   @Test
/*      */   public void allDataSources() throws Exception {
/* 1212 */     String filter = LegacyLdapFilter.allDataSources();
/* 1213 */     ZLdapFilter zLdapFilter = filterDactory.allDataSources();
/* 1214 */     verify(ZLdapFilterFactory.FilterId.ALL_DATA_SOURCES, filter, zLdapFilter);
/*      */   }
/*      */   
/*      */   @Test
/*      */   public void dataSourceById() throws Exception {
/* 1219 */     String ID = genUUID();
/*      */     
/* 1221 */     String filter = LegacyLdapFilter.dataSourceById(ID);
/* 1222 */     ZLdapFilter zLdapFilter = filterDactory.dataSourceById(ID);
/* 1223 */     verify(ZLdapFilterFactory.FilterId.DATA_SOURCE_BY_ID, filter, zLdapFilter);
/*      */   }
/*      */   
/*      */   @Test
/*      */   public void dataSourceByName() throws Exception {
/* 1228 */     String NAME = getTestName();
/*      */     
/* 1230 */     String filter = LegacyLdapFilter.dataSourceByName(NAME);
/* 1231 */     ZLdapFilter zLdapFilter = filterDactory.dataSourceByName(NAME);
/* 1232 */     verify(ZLdapFilterFactory.FilterId.DATA_SOURCE_BY_NAME, filter, zLdapFilter);
/*      */   }
/*      */   
/*      */   @Test
/*      */   public void allDistributionLists() throws Exception {
/* 1237 */     String filter = LegacyLdapFilter.allDistributionLists();
/* 1238 */     ZLdapFilter zLdapFilter = filterDactory.allDistributionLists();
/* 1239 */     verify(ZLdapFilterFactory.FilterId.ALL_DISTRIBUTION_LISTS, filter, zLdapFilter);
/*      */   }
/*      */   
/*      */   @Test
/*      */   public void distributionListById() throws Exception {
/* 1244 */     String ID = genUUID();
/*      */     
/* 1246 */     String filter = LegacyLdapFilter.distributionListById(ID);
/* 1247 */     ZLdapFilter zLdapFilter = filterDactory.distributionListById(ID);
/* 1248 */     verify(ZLdapFilterFactory.FilterId.DISTRIBUTION_LIST_BY_ID, filter, zLdapFilter);
/*      */   }
/*      */   
/*      */   @Test
/*      */   public void distributionListByName() throws Exception {
/* 1253 */     String NAME = getTestName();
/*      */     
/* 1255 */     String filter = LegacyLdapFilter.distributionListByName(NAME);
/* 1256 */     ZLdapFilter zLdapFilter = filterDactory.distributionListByName(NAME);
/* 1257 */     verify(ZLdapFilterFactory.FilterId.DISTRIBUTION_LIST_BY_NAME, filter, zLdapFilter);
/*      */   }
/*      */   
/*      */   @Test
/*      */   public void distributionListsByMemberAddrs() throws Exception {
/* 1262 */     String[] MEMBER_ADDRS = { "addr1@test.com", "addr2@test.com", "addr3@test.com" };
/*      */     
/* 1264 */     String filter = LegacyLdapFilter.distributionListsByMemberAddrs(MEMBER_ADDRS);
/* 1265 */     ZLdapFilter zLdapFilter = filterDactory.distributionListsByMemberAddrs(MEMBER_ADDRS);
/* 1266 */     verify(ZLdapFilterFactory.FilterId.DISTRIBUTION_LISTS_BY_MEMBER_ADDRS, filter, zLdapFilter);
/*      */   }
/*      */   
/*      */   @Test
/*      */   public void dynamicGroupById() throws Exception {
/* 1271 */     String ID = genUUID();
/*      */     
/* 1273 */     String filter = LegacyLdapFilter.dynamicGroupById(ID);
/* 1274 */     ZLdapFilter zLdapFilter = filterDactory.dynamicGroupById(ID);
/* 1275 */     verify(ZLdapFilterFactory.FilterId.DYNAMIC_GROUP_BY_ID, filter, zLdapFilter);
/*      */   }
/*      */   
/*      */   @Test
/*      */   public void dynamicGroupByName() throws Exception {
/* 1280 */     String NAME = getTestName();
/*      */     
/* 1282 */     String filter = LegacyLdapFilter.dynamicGroupByName(NAME);
/* 1283 */     ZLdapFilter zLdapFilter = filterDactory.dynamicGroupByName(NAME);
/* 1284 */     verify(ZLdapFilterFactory.FilterId.DYNAMIC_GROUP_BY_NAME, filter, zLdapFilter);
/*      */   }
/*      */   
/*      */   @Test
/*      */   public void groupById() throws Exception
/*      */   {
/* 1290 */     String ID = genUUID();
/*      */     
/* 1292 */     String filter = LegacyLdapFilter.groupById(ID);
/* 1293 */     ZLdapFilter zLdapFilter = filterDactory.groupById(ID);
/* 1294 */     verify(ZLdapFilterFactory.FilterId.GROUP_BY_ID, filter, zLdapFilter);
/*      */   }
/*      */   
/*      */   @Test
/*      */   public void groupByName() throws Exception {
/* 1299 */     String NAME = getTestName();
/*      */     
/* 1301 */     String filter = LegacyLdapFilter.groupByName(NAME);
/* 1302 */     ZLdapFilter zLdapFilter = filterDactory.groupByName(NAME);
/* 1303 */     verify(ZLdapFilterFactory.FilterId.GROUP_BY_NAME, filter, zLdapFilter);
/*      */   }
/*      */   
/*      */   @Test
/*      */   public void allDomains() throws Exception {
/* 1308 */     String filter = LegacyLdapFilter.allDomains();
/* 1309 */     ZLdapFilter zLdapFilter = filterDactory.allDomains();
/* 1310 */     verify(ZLdapFilterFactory.FilterId.ALL_DOMAINS, filter, zLdapFilter);
/*      */   }
/*      */   
/*      */   @Test
/*      */   public void domainById() throws Exception {
/* 1315 */     String ID = genUUID();
/*      */     
/* 1317 */     String filter = LegacyLdapFilter.domainById(ID);
/* 1318 */     ZLdapFilter zLdapFilter = filterDactory.domainById(ID);
/* 1319 */     verify(ZLdapFilterFactory.FilterId.DOMAIN_BY_ID, filter, zLdapFilter);
/*      */   }
/*      */   
/*      */   @Test
/*      */   public void domainByName() throws Exception {
/* 1324 */     String NAME = getTestName();
/*      */     
/* 1326 */     String filter = LegacyLdapFilter.domainByName(NAME);
/* 1327 */     ZLdapFilter zLdapFilter = filterDactory.domainByName(NAME);
/* 1328 */     verify(ZLdapFilterFactory.FilterId.DOMAIN_BY_NAME, filter, zLdapFilter);
/*      */   }
/*      */   
/*      */   @Test
/*      */   public void domainByKrb5Realm() throws Exception {
/* 1333 */     String REALM = getTestName();
/*      */     
/* 1335 */     String filter = LegacyLdapFilter.domainByKrb5Realm(REALM);
/* 1336 */     ZLdapFilter zLdapFilter = filterDactory.domainByKrb5Realm(REALM);
/* 1337 */     verify(ZLdapFilterFactory.FilterId.DOMAIN_BY_KRB5_REALM, filter, zLdapFilter);
/*      */   }
/*      */   
/*      */   @Test
/*      */   public void domainByVirtualHostame() throws Exception {
/* 1342 */     String VIRTUAL_HOST_NAME = getTestName();
/*      */     
/* 1344 */     String filter = LegacyLdapFilter.domainByVirtualHostame(VIRTUAL_HOST_NAME);
/* 1345 */     ZLdapFilter zLdapFilter = filterDactory.domainByVirtualHostame(VIRTUAL_HOST_NAME);
/* 1346 */     verify(ZLdapFilterFactory.FilterId.DOMAIN_BY_VIRTUAL_HOSTNAME, filter, zLdapFilter);
/*      */   }
/*      */   
/*      */   @Test
/*      */   public void domainByForeignName() throws Exception {
/* 1351 */     String FOREIGN_NAME = getTestName();
/*      */     
/* 1353 */     String filter = LegacyLdapFilter.domainByForeignName(FOREIGN_NAME);
/* 1354 */     ZLdapFilter zLdapFilter = filterDactory.domainByForeignName(FOREIGN_NAME);
/* 1355 */     verify(ZLdapFilterFactory.FilterId.DOMAIN_BY_FOREIGN_NAME, filter, zLdapFilter);
/*      */   }
/*      */   
/*      */   @Test
/*      */   public void domainLabel() throws Exception {
/* 1360 */     String filter = LegacyLdapFilter.domainLabel();
/* 1361 */     ZLdapFilter zLdapFilter = filterDactory.domainLabel();
/* 1362 */     verify(ZLdapFilterFactory.FilterId.DOMAIN_LABEL, filter, zLdapFilter);
/*      */   }
/*      */   
/*      */   @Test
/*      */   public void domainLockedForEagerAutoProvision() throws Exception {
/* 1367 */     String filter = LegacyLdapFilter.domainLockedForEagerAutoProvision();
/* 1368 */     ZLdapFilter zLdapFilter = filterDactory.domainLockedForEagerAutoProvision();
/* 1369 */     verify(ZLdapFilterFactory.FilterId.DOMAIN_LOCKED_FOR_AUTO_PROVISION, filter, zLdapFilter);
/*      */   }
/*      */   
/*      */   @Test
/*      */   public void globalConfig() throws Exception {
/* 1374 */     String filter = LegacyLdapFilter.globalConfig();
/* 1375 */     ZLdapFilter zLdapFilter = filterDactory.globalConfig();
/* 1376 */     verify(ZLdapFilterFactory.FilterId.GLOBAL_CONFIG, filter, zLdapFilter);
/*      */   }
/*      */   
/*      */   @Test
/*      */   public void allIdentities() throws Exception {
/* 1381 */     String filter = LegacyLdapFilter.allIdentities();
/* 1382 */     ZLdapFilter zLdapFilter = filterDactory.allIdentities();
/* 1383 */     verify(ZLdapFilterFactory.FilterId.ALL_IDENTITIES, filter, zLdapFilter);
/*      */   }
/*      */   
/*      */   @Test
/*      */   public void identityByName() throws Exception {
/* 1388 */     String NAME = getTestName();
/*      */     
/* 1390 */     String filter = LegacyLdapFilter.identityByName(NAME);
/* 1391 */     ZLdapFilter zLdapFilter = filterDactory.identityByName(NAME);
/* 1392 */     verify(ZLdapFilterFactory.FilterId.IDENTITY_BY_NAME, filter, zLdapFilter);
/*      */   }
/*      */   
/*      */   @Test
/*      */   public void allMimeEntries() throws Exception {
/* 1397 */     String filter = LegacyLdapFilter.allMimeEntries();
/* 1398 */     ZLdapFilter zLdapFilter = filterDactory.allMimeEntries();
/* 1399 */     verify(ZLdapFilterFactory.FilterId.ALL_MIME_ENTRIES, filter, zLdapFilter);
/*      */   }
/*      */   
/*      */   @Test
/*      */   public void mimeEntryByMimeType() throws Exception {
/* 1404 */     String MIME_TYPE = getTestName();
/*      */     
/* 1406 */     String filter = LegacyLdapFilter.mimeEntryByMimeType(MIME_TYPE);
/* 1407 */     ZLdapFilter zLdapFilter = filterDactory.mimeEntryByMimeType(MIME_TYPE);
/* 1408 */     verify(ZLdapFilterFactory.FilterId.MIME_ENTRY_BY_MIME_TYPE, filter, zLdapFilter);
/*      */   }
/*      */   
/*      */   @Test
/*      */   public void allServers() throws Exception {
/* 1413 */     String filter = LegacyLdapFilter.allServers();
/* 1414 */     ZLdapFilter zLdapFilter = filterDactory.allServers();
/* 1415 */     verify(ZLdapFilterFactory.FilterId.ALL_SERVERS, filter, zLdapFilter);
/*      */   }
/*      */   
/*      */   @Test
/*      */   public void serverById() throws Exception {
/* 1420 */     String ID = genUUID();
/*      */     
/* 1422 */     String filter = LegacyLdapFilter.serverById(ID);
/* 1423 */     ZLdapFilter zLdapFilter = filterDactory.serverById(ID);
/* 1424 */     verify(ZLdapFilterFactory.FilterId.SERVER_BY_ID, filter, zLdapFilter);
/*      */   }
/*      */   
/*      */   @Test
/*      */   public void serverByService() throws Exception {
/* 1429 */     String SERVICE = getTestName();
/*      */     
/* 1431 */     String filter = LegacyLdapFilter.serverByService(SERVICE);
/* 1432 */     ZLdapFilter zLdapFilter = filterDactory.serverByService(SERVICE);
/* 1433 */     verify(ZLdapFilterFactory.FilterId.SERVER_BY_SERVICE, filter, zLdapFilter);
/*      */   }
/*      */   
/*      */   @Test
/*      */   public void allSignatures() throws Exception {
/* 1438 */     String filter = LegacyLdapFilter.allSignatures();
/* 1439 */     ZLdapFilter zLdapFilter = filterDactory.allSignatures();
/* 1440 */     verify(ZLdapFilterFactory.FilterId.ALL_SIGNATURES, filter, zLdapFilter);
/*      */   }
/*      */   
/*      */   @Test
/*      */   public void signatureById() throws Exception {
/* 1445 */     String ID = genUUID();
/*      */     
/* 1447 */     String filter = LegacyLdapFilter.signatureById(ID);
/* 1448 */     ZLdapFilter zLdapFilter = filterDactory.signatureById(ID);
/* 1449 */     verify(ZLdapFilterFactory.FilterId.SIGNATURE_BY_ID, filter, zLdapFilter);
/*      */   }
/*      */   
/*      */   @Test
/*      */   public void allXMPPComponents() throws Exception {
/* 1454 */     String filter = LegacyLdapFilter.allXMPPComponents();
/* 1455 */     ZLdapFilter zLdapFilter = filterDactory.allXMPPComponents();
/* 1456 */     verify(ZLdapFilterFactory.FilterId.ALL_XMPP_COMPONENTS, filter, zLdapFilter);
/*      */   }
/*      */   
/*      */   @Test
/*      */   public void imComponentById() throws Exception {
/* 1461 */     String ID = genUUID();
/*      */     
/* 1463 */     String filter = LegacyLdapFilter.imComponentById(ID);
/* 1464 */     ZLdapFilter zLdapFilter = filterDactory.imComponentById(ID);
/* 1465 */     verify(ZLdapFilterFactory.FilterId.XMPP_COMPONENT_BY_ZIMBRA_XMPP_COMPONENT_ID, filter, zLdapFilter);
/*      */   }
/*      */   
/*      */   @Test
/*      */   public void xmppComponentById() throws Exception {
/* 1470 */     String ID = genUUID();
/*      */     
/* 1472 */     String filter = LegacyLdapFilter.xmppComponentById(ID);
/* 1473 */     ZLdapFilter zLdapFilter = filterDactory.xmppComponentById(ID);
/* 1474 */     verify(ZLdapFilterFactory.FilterId.XMPP_COMPONENT_BY_ID, filter, zLdapFilter);
/*      */   }
/*      */   
/*      */   @Test
/*      */   public void allZimlets() throws Exception {
/* 1479 */     String filter = LegacyLdapFilter.allZimlets();
/* 1480 */     ZLdapFilter zLdapFilter = filterDactory.allZimlets();
/* 1481 */     verify(ZLdapFilterFactory.FilterId.ALL_ZIMLETS, filter, zLdapFilter);
/*      */   }
/*      */   
/*      */   @Test
/*      */   @QA.Bug(bug={64260})
/*      */   public void bug64260() throws Exception {
/* 1487 */     String badStringFilter = "ad:(&(|(displayName=*%s*)(cn=*%s*)(sn=*%s*)(givenName=*%s*)(mail=*%s*))(!(msExchHideFromAddressLists=TRUE))(!(displayName=*(EMC)))(mailnickname=*)(|(&(objectCategory=person)(objectClass=user)(!(homeMDB=*))(!(msExchHomeServerName=*)))(&(objectCategory=person)(objectClass=user)(|(homeMDB=*)(msExchHomeServerName=*)))(&(objectCategory=person)(objectClass=contact))(objectCategory=group)(objectCategory=publicFolder)(objectCategory=msExchDynamicDistributionList)))";
/*      */     
/*      */ 
/*      */ 
/* 1491 */     boolean caughtException = false;
/*      */     try
/*      */     {
/* 1494 */       filter = filterDactory.fromFilterString(ZLdapFilterFactory.FilterId.UNITTEST, badStringFilter);
/*      */     }
/*      */     catch (LdapException e) {
/* 1497 */       if ("ldap.INVALID_SEARCH_FILTER".equals(e.getCode())) {
/* 1498 */         caughtException = true;
/*      */       }
/*      */     }
/*      */     
/* 1502 */     Assert.assertTrue(caughtException);
/*      */     
/* 1504 */     String goodStringFilter = "(&(|(displayName=*)(cn=*)(sn=*)(givenName=*)(mail=*))(!(msExchHideFromAddressLists=TRUE))(!(displayName=*\\28EMC\\29))(mailnickname=*)(|(&(objectCategory=person)(objectClass=user)(!(homeMDB=*))(!(msExchHomeServerName=*)))(&(objectCategory=person)(objectClass=user)(|(homeMDB=*)(msExchHomeServerName=*)))(&(objectCategory=person)(objectClass=contact))(objectCategory=group)(objectCategory=publicFolder)(objectCategory=msExchDynamicDistributionList)))";
/*      */     
/* 1506 */     ZLdapFilter filter = filterDactory.fromFilterString(ZLdapFilterFactory.FilterId.UNITTEST, goodStringFilter);
/*      */   }
/*      */   
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */   @Test
/*      */   public void autoProvisionSearchCreatedLaterThan()
/*      */     throws Exception
/*      */   {
/* 1526 */     String FILTER = "(foo=bar)";
/* 1527 */     String GENERALIZED_TIME = "20111005190522Z";
/*      */     
/* 1529 */     String filter = "(&" + FILTER + "(createTimestamp>=" + GENERALIZED_TIME + "))";
/*      */     
/* 1531 */     ZLdapFilter createdLaterThanFilter = filterDactory.createdLaterOrEqual(GENERALIZED_TIME);
/* 1532 */     String filter2 = "(&" + FILTER + createdLaterThanFilter.toFilterString() + ")";
/*      */     
/* 1534 */     Assert.assertEquals(filter, filter2);
/*      */     
/* 1536 */     ZLdapFilter zLdapFilter = filterDactory.fromFilterString(ZLdapFilterFactory.FilterId.AUTO_PROVISION_SEARCH_CREATED_LATERTHAN, filter2);
/*      */     
/* 1538 */     verifyStatString(ZLdapFilterFactory.FilterId.AUTO_PROVISION_SEARCH_CREATED_LATERTHAN, zLdapFilter);
/*      */   }
/*      */   
/*      */   @Test
/*      */   public void memberOf() throws Exception {
/* 1543 */     String DN = "dc=com";
/*      */     
/* 1545 */     String filter = LegacyLdapFilter.memberOf(DN);
/* 1546 */     ZLdapFilter zLdapFilter = filterDactory.memberOf(DN);
/* 1547 */     verify(ZLdapFilterFactory.FilterId.MEMBER_OF, filter, zLdapFilter);
/*      */   }
/*      */   
/*      */   @Test
/*      */   public void velodromeAllAccountsByDomain() throws Exception {
/* 1552 */     String DOMAIN_NAME = "test.com";
/*      */     
/* 1554 */     String filter = LegacyLdapFilter.velodromeAllAccountsByDomain(DOMAIN_NAME);
/* 1555 */     ZLdapFilter zLdapFilter = filterDactory.velodromeAllAccountsByDomain(DOMAIN_NAME);
/* 1556 */     verify(ZLdapFilterFactory.FilterId.VELODROME_ALL_ACCOUNTS_BY_DOMAIN, filter, zLdapFilter);
/*      */   }
/*      */   
/*      */   @Test
/*      */   public void velodromeAllAccountsOnlyByDomain() throws Exception {
/* 1561 */     String DOMAIN_NAME = "test.com";
/*      */     
/* 1563 */     String filter = LegacyLdapFilter.velodromeAllAccountsOnlyByDomain(DOMAIN_NAME);
/* 1564 */     ZLdapFilter zLdapFilter = filterDactory.velodromeAllAccountsOnlyByDomain(DOMAIN_NAME);
/* 1565 */     verify(ZLdapFilterFactory.FilterId.VELODROME_ALL_ACCOUNTS_ONLY_BY_DOMAIN, filter, zLdapFilter);
/*      */   }
/*      */   
/*      */   @Test
/*      */   public void velodromeAllCalendarResourcesByDomain() throws Exception {
/* 1570 */     String DOMAIN_NAME = "test.com";
/*      */     
/* 1572 */     String filter = LegacyLdapFilter.velodromeAllCalendarResourcesByDomain(DOMAIN_NAME);
/* 1573 */     ZLdapFilter zLdapFilter = filterDactory.velodromeAllCalendarResourcesByDomain(DOMAIN_NAME);
/* 1574 */     verify(ZLdapFilterFactory.FilterId.VELODROME_ALL_CALENDAR_RESOURCES_BY_DOMAIN, filter, zLdapFilter);
/*      */   }
/*      */   
/*      */   @Test
/*      */   public void velodromeAllAccountsByDomainAndServer() throws Exception {
/* 1579 */     String DOMAIN_NAME = "test.com";
/* 1580 */     String SERVER_SERVICE_HOSTNAME = "server.com";
/*      */     
/* 1582 */     String filter = LegacyLdapFilter.velodromeAllAccountsByDomainAndServer(DOMAIN_NAME, SERVER_SERVICE_HOSTNAME);
/* 1583 */     ZLdapFilter zLdapFilter = filterDactory.velodromeAllAccountsByDomainAndServer(DOMAIN_NAME, SERVER_SERVICE_HOSTNAME);
/* 1584 */     verify(ZLdapFilterFactory.FilterId.VELODROME_ALL_ACCOUNTS_BY_DOMAIN_AND_SERVER, filter, zLdapFilter);
/*      */   }
/*      */   
/*      */   @Test
/*      */   public void velodromeAllAccountsOnlyByDomainAndServer() throws Exception {
/* 1589 */     String DOMAIN_NAME = "test.com";
/* 1590 */     String SERVER_SERVICE_HOSTNAME = "server.com";
/*      */     
/* 1592 */     String filter = LegacyLdapFilter.velodromeAllAccountsOnlyByDomainAndServer(DOMAIN_NAME, SERVER_SERVICE_HOSTNAME);
/* 1593 */     ZLdapFilter zLdapFilter = filterDactory.velodromeAllAccountsOnlyByDomainAndServer(DOMAIN_NAME, SERVER_SERVICE_HOSTNAME);
/* 1594 */     verify(ZLdapFilterFactory.FilterId.VELODROME_ALL_ACCOUNTS_ONLY_BY_DOMAIN_AND_SERVER, filter, zLdapFilter);
/*      */   }
/*      */   
/*      */   @Test
/*      */   public void velodromeAllCalendarResourcesByDomainAndServer() throws Exception {
/* 1599 */     String DOMAIN_NAME = "test.com";
/* 1600 */     String SERVER_SERVICE_HOSTNAME = "server.com";
/*      */     
/* 1602 */     String filter = LegacyLdapFilter.velodromeAllCalendarResourcesByDomainAndServer(DOMAIN_NAME, SERVER_SERVICE_HOSTNAME);
/* 1603 */     ZLdapFilter zLdapFilter = filterDactory.velodromeAllCalendarResourcesByDomainAndServer(DOMAIN_NAME, SERVER_SERVICE_HOSTNAME);
/* 1604 */     verify(ZLdapFilterFactory.FilterId.VELODROME_ALL_CALENDAR_RESOURCES_BY_DOMAIN_AND_SERVER, filter, zLdapFilter);
/*      */   }
/*      */   
/*      */   @Test
/*      */   public void dnSubtreeMatch() throws Exception {
/* 1609 */     String DN1 = "ou=people,dc=test,dc=com";
/* 1610 */     String DN2 = "cn=groups,dc=test,dc=com";
/*      */     
/* 1612 */     String filter = LegacyLdapFilter.dnSubtreeMatch(new String[] { DN1, DN2 });
/* 1613 */     ZLdapFilter zLdapFilter = filterDactory.dnSubtreeMatch(new String[] { DN1, DN2 });
/* 1614 */     verify(ZLdapFilterFactory.FilterId.DN_SUBTREE_MATCH, filter, zLdapFilter);
/*      */   }
/*      */   
/*      */   @Test
/*      */   public void toIDNFilter() throws Exception {
/* 1619 */     Assert.assertEquals("(!(zimbraDomainName=*中文*))", LdapEntrySearchFilter.toLdapIDNFilter("(!(zimbraDomainName=*中文*))"));
/*      */     
/*      */ 
/* 1622 */     Assert.assertEquals("(objectClass=*)", LdapEntrySearchFilter.toLdapIDNFilter("(objectClass=*)"));
/*      */     
/*      */ 
/*      */ 
/* 1626 */     Assert.assertEquals("(!(objectClass=**))", LdapEntrySearchFilter.toLdapIDNFilter("(!(objectClass=**))"));
/*      */     
/*      */ 
/* 1629 */     Assert.assertEquals("(!(objectClass=*abc))", LdapEntrySearchFilter.toLdapIDNFilter("(!(objectClass=*abc))"));
/*      */     
/*      */ 
/* 1632 */     Assert.assertEquals("(!(objectClass=abc*))", LdapEntrySearchFilter.toLdapIDNFilter("(!(objectClass=abc*))"));
/*      */     
/*      */ 
/* 1635 */     Assert.assertEquals("(!(objectClass=*abc*))", LdapEntrySearchFilter.toLdapIDNFilter("!(objectClass=*abc*)"));
/*      */     
/*      */ 
/* 1638 */     Assert.assertEquals("(|(zimbraMailDeliveryAddress=*@test.xn--fiq228c.com)(zimbraMailAlias=*@test.xn--fiq228c.com))", LdapEntrySearchFilter.toLdapIDNFilter("(|(zimbraMailDeliveryAddress=*@test.中文.com)(zimbraMailAlias=*@test.中文.com))"));
/*      */   }
/*      */   
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */   @Test
/*      */   @QA.Bug(bug={68964})
/*      */   public void toIDNFilterTrailingDot()
/*      */     throws Exception
/*      */   {
/* 1672 */     Assert.assertEquals("(zimbraMailDeliveryAddress=.)", LdapEntrySearchFilter.toLdapIDNFilter("(zimbraMailDeliveryAddress=.)"));
/*      */     
/*      */ 
/* 1675 */     Assert.assertEquals("(zimbraMailDeliveryAddress=...)", LdapEntrySearchFilter.toLdapIDNFilter("(zimbraMailDeliveryAddress=...)"));
/*      */     
/*      */ 
/* 1678 */     Assert.assertEquals("(zimbraMailDeliveryAddress=.a.)", LdapEntrySearchFilter.toLdapIDNFilter("(zimbraMailDeliveryAddress=.a.)"));
/*      */     
/*      */ 
/* 1681 */     Assert.assertEquals("(zimbraMailDeliveryAddress=a.b.)", LdapEntrySearchFilter.toLdapIDNFilter("(zimbraMailDeliveryAddress=a.b.)"));
/*      */     
/*      */ 
/* 1684 */     Assert.assertEquals("(zimbraMailDeliveryAddress=*.*)", LdapEntrySearchFilter.toLdapIDNFilter("(zimbraMailDeliveryAddress=*.*)"));
/*      */   }
/*      */   
/*      */   @Test
/*      */   @QA.Bug(bug={68965})
/*      */   public void toIDNFilterWithCharsNeedEscaping() throws Exception
/*      */   {
/* 1691 */     Assert.assertEquals("(objectClass=*\\2a*)", LdapEntrySearchFilter.toLdapIDNFilter("(objectClass=*\\2a*)"));
/*      */     
/*      */ 
/* 1694 */     Assert.assertEquals("(objectClass=*\\28*)", LdapEntrySearchFilter.toLdapIDNFilter("(objectClass=*\\28*)"));
/*      */     
/*      */ 
/* 1697 */     Assert.assertEquals("(objectClass=*\\29*)", LdapEntrySearchFilter.toLdapIDNFilter("(objectClass=*\\29*)"));
/*      */     
/*      */ 
/* 1700 */     Assert.assertEquals("(objectClass=*\\5c*)", LdapEntrySearchFilter.toLdapIDNFilter("(objectClass=*\\5c*)"));
/*      */   }
/*      */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/qa/unittest/prov/ldap/TestLdapZLdapFilter.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */